Ext.define('SKJF.view.PENJUALAN.v_fakturpajak_form', {
	extend	: 'Ext.form.Panel',
	
	alias	: 'widget.v_fakturpajak_form',
	
	//region:'east',
	//id: 'east-region-container',
	
	title		: 'Create/Update fakturpajak',
    bodyPadding	: 5,
    autoScroll	: true,
    
    initComponent: function(){
    	/*
		 * Deklarasi variable setiap field
		 */
		
		var inv_store = Ext.create('SKJF.store.s_do',{autoLoad:true});
		
		var NOMOR_FAKTUR_field = Ext.create('Ext.form.field.Text', {
			itemId: 'NOMOR_FAKTUR_field',
			name: 'NOMOR_FAKTUR', /* column name of table */
			fieldLabel: 'NOMOR_FAKTUR',
			readOnly: true
		});
		var TANGGAL_FAKTUR_field = Ext.create('Ext.form.field.Date', {
			name: 'TANGGAL_FAKTUR', /* column name of table */
			format: 'Y-m-d',
			fieldLabel: 'TANGGAL_FAKTUR',
			value: new Date()
		});
		var KODE_CUSTOMER_field = Ext.create('Ext.form.field.Text', {
			name: 'KODE_CUSTOMER', /* column name of table */
			fieldLabel: 'KODE_CUSTOMER',
			readOnly: true
		});
		var NAMA_CUSTOMER_field = Ext.create('Ext.form.field.Text', {
			name: 'NAMA_CUSTOMER', /* column name of table */
			fieldLabel: 'NAMA_CUSTOMER',
			readOnly: true
		});
		var NOMOR_INVOICE_field = Ext.create('Ext.form.field.ComboBox', {
			itemId: 'NOMOR_INVOICE_field',
			name: 'NOMOR_INVOICE', /* column name of table */
			fieldLabel: 'NOMOR_INVOICE',
			pageSize: 10,
			typeAhead    : true,
			triggerAction: 'all',
			selectOnFocus: true,
            loadingText  : 'Searching...',
			store: inv_store,
			queryMode: 'local',
			tpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'<div class="x-boundlist-item">{NOMOR_INVOICE}</div>',
				'</tpl>'
			),
			displayTpl: Ext.create('Ext.XTemplate',
				'<tpl for=".">',
					'{NOMOR_INVOICE}',
				'</tpl>'
			),
			valueField: 'NOMOR_INVOICE',
			displayField: 'NOMOR_INVOICE',
			enableKeyEvents: true,
			listeners: {
				select: function(combo, records, e){
					KODE_CUSTOMER_field.setValue(records[0].data.KODE_CUSTOMER);
					NAMA_CUSTOMER_field.setValue(records[0].data.NAMA_CUSTOMER);
				}
			}
		});
		var DIBUAT_OLEH_field = Ext.create('Ext.form.field.Text', {
			name: 'DIBUAT_OLEH', /* column name of table */
			fieldLabel: 'DIBUAT_OLEH',
			value: username,
			readOnly: true
		});
		var JUMLAH_EDIT_field = Ext.create('Ext.form.field.Number', {
			name: 'JUMLAH_EDIT', /* column name of table */
			fieldLabel: 'JUMLAH_EDIT',
			readOnly: true
		});
		var TANGGAL_EDIT_field = Ext.create('Ext.form.field.Date', {
			name: 'TANGGAL_EDIT', /* column name of table */
			format: 'Y-m-d',
			fieldLabel: 'TANGGAL_EDIT',
			value: new Date(),
			readOnly: true
		});		
        Ext.apply(this, {
            fieldDefaults: {
                labelAlign: 'right',
                labelWidth: 120,
                msgTarget: 'qtip',
				anchor: '100%'
            },
			defaultType: 'textfield',
            items: [NOMOR_FAKTUR_field,TANGGAL_FAKTUR_field,NOMOR_INVOICE_field,KODE_CUSTOMER_field,NAMA_CUSTOMER_field,DIBUAT_OLEH_field,JUMLAH_EDIT_field,TANGGAL_EDIT_field],
			
	        buttons: [{
                iconCls: 'icon-save',
                itemId: 'save',
                text: 'Save',
                disabled: true,
                action: 'save'
            }, {
                iconCls: 'icon-add',
				itemId: 'create',
                text: 'Create',
                action: 'create'
            }, {
                iconCls: 'icon-reset',
                text: 'Cancel',
                action: 'cancel'
            }]
        });
        
        this.callParent();
    }
});